package com.cherry.common.util;

import org.apache.commons.lang3.StringUtils;

import java.util.UUID;

/**
 * ID工具类
 *
 * @author sinbad.cheng
 * @since 2022-01-14
 */
public class IdUtil {

    public static final SnowflakeIdGenerator SNOWFLAKE_ID_GENERATOR = new SnowflakeIdGenerator(0, 0);

    private IdUtil() {
    }

    public static String uuid() {
        return UUID.randomUUID().toString();
    }

    public static String uuid2() {
        String uuid = UUID.randomUUID().toString();
        return StringUtils.replace(uuid, "-", "");
    }

    public static long snowflakeId() {
        return SNOWFLAKE_ID_GENERATOR.nextId();
    }

    public static String snowflakeIdStr() {
        return String.valueOf(SNOWFLAKE_ID_GENERATOR.nextId());
    }

}